import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Test {//用洛谷提交代码，主类名一定要用Main
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String str = scanner.nextLine();
            for (String s : str.split(" ")) {
                list.add(Integer.parseInt(s));
            }
        }
        Integer[] nums = new Integer[list.size()];
        nums = list.toArray(nums);
        Arrays.sort(nums);
        int a = 0, b = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] - nums[i - 1] > 1) {
                a = nums[i - 1] + 1;
            }
            if (nums[i].equals(nums[i - 1])) {
                b = nums[i - 1];
            }
            if (a * b > 0) {
                System.out.println(a + " " + b);
                break;
            }
        }
    }
}